package ptij.vocoder.baseModel.lp_analysis;

import ptolemy.actor.*;
import ptolemy.kernel.*;
import ptolemy.kernel.util.*;
import ptolemy.data.ObjectToken;
import ptolemy.data.type.*;

import ptij.vocoder.baseModel.*;

//////////////////////////////////////////////////////////////////////////
//// Levinson
/**

@author Ivan Jeukens
@version v 0.1 07/08/2003
*/
public class Levinson extends TypedAtomicActor {

    public Levinson(CompositeEntity container, String name) throws
            IllegalActionException, NameDuplicationException {
        super(container, name);
        
        r_h = new TypedIOPort(this, "r_h", true, false);
        r_h.setTypeEquals(BaseType.OBJECT);
        
        r_l = new TypedIOPort(this, "r_l", true, false);
        r_l.setTypeEquals(BaseType.OBJECT);
        
        rc = new TypedIOPort(this, "rc", false, true);
        rc.setTypeEquals(BaseType.OBJECT);
        
        A = new TypedIOPort(this, "A", false, true);
        A.setTypeEquals(BaseType.OBJECT);
    }

    ///////////////////////////////////////////////////////////////////
    ////                     ports and parameters                  ////

    // Input ports
    public TypedIOPort r_h;
    public TypedIOPort r_l;

    // Output Ports
    public TypedIOPort rc;
    public TypedIOPort A;

    ///////////////////////////////////////////////////////////////////
    ////                         public methods                    ////

    public void initialize() throws IllegalActionException {
        super.initialize();
        _oldA = new Short[Cnst.MP1];
        _init();
    }
    
    public void fire() throws IllegalActionException {
        ObjectToken obj = (ObjectToken) r_h.get(0);
        Short [] arg1 = (Short []) obj.getValue();
        
        obj = (ObjectToken) r_l.get(0);
        Short [] arg2 = (Short []) obj.getValue();
        
        Short [] arg3 = new Short[Cnst.M];
        Short [] arg4 = new Short[4];

        _levinson(arg1, arg2, arg3, arg4);

        obj = new ObjectToken(arg3);
        A.broadcast(obj);

        obj = new ObjectToken(arg4);
        rc.broadcast(obj);
    }

    ///////////////////////////////////////////////////////////////////
    ////                         private methods                   ////

    private void _levinson(Short [] arg1, Short [] arg2, Short [] arg3,
            Short [] arg4) {
        
    }
    
    // tem que inicializar o oldA.
    private void _init() {
        
    }
    
    ///////////////////////////////////////////////////////////////////
    ////                         private variables                 ////

    private Short [] _oldA;
}

